package com.longxiao.service;

import com.longxiao.entity.ClientVersion;
import com.longxiao.mapper.ClientVersionMapper;
import com.longxiao.para.VersionSearchPara;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * Created by yusong on 2017/6/14.
 * 管理后台版本服务
 */
@Service
public class VersionService {


    @Resource
    private ClientVersionMapper clientVersionMapper;


    /*
   *分页搜索版本信息
   */
    public List<ClientVersion> listByPage(VersionSearchPara versionSearchPara){
        List<ClientVersion> entities = clientVersionMapper.listVersion(versionSearchPara);
        return entities;
    }

    /*
   *获取用户总数
   */
    public Integer count(VersionSearchPara versionSearchPara){
        return clientVersionMapper.count(versionSearchPara);
    }


    /*
    *插入版本信息
    */
    public void addVersion(ClientVersion clientVersion){
        clientVersion.setStatus(Boolean.TRUE);
        clientVersion.setCreatedTime(new Date());
        clientVersion.setModifiedTime(clientVersion.getCreatedTime());
        clientVersionMapper.insert(clientVersion);
    }

    /*
    *通过ID获取记录
     */
    public ClientVersion getById(Integer id){
        return clientVersionMapper.selectByPrimaryKey(id);
    }

    /*
    *插入版本信息
    */
    public void update(ClientVersion clientVersion){
        clientVersion.setModifiedTime(clientVersion.getCreatedTime());
        clientVersionMapper.updateByPrimaryKey(clientVersion);
    }

    /*
    *删除记录
    */
    public int delete(Integer id){
        return clientVersionMapper.deleteByPrimaryKey(id);
    }

}
